#include "error_check.h"

Error_check::Error_check()
{
}
bool Error_check::Illegal_char_check(QString error_name,QLineEdit *temp)
{
    QString warn;
    warn.clear();
    for(int i = 0; i < temp->text().count(); i++)
        if(temp->text().at(i) < 48 || (temp->text().at(i) > 57 && temp->text().at(i) < 65) || (temp->text().at(i) > 90 && temp->text().at(i) < 97) || temp->text().at(i) > 122){
            warn += "Illegal char '";
            warn += temp->text().at(i);
            warn += "\'!";
            error_play(error_name,warn);
            return true;
        }
    //qDebug()<<temp->text().count();
    if(6 != temp->text().count()){
        error_play(error_name,"Size isn't 6!");
        return true;
    }
    return false;
}

void Error_check::format(QByteArray *head,QString count,int size,char c)
{
    for(int i=0;i<size-count.count();i++)
        *head += c;
}

void Error_check::error_play(QString head,QString last)
{
     ui->Error_message->setText(head + ":\t" + last);
     this->show();
}

Error::~Error()
{
    delete ui;
}
